<?php
/**
 * QQAS - share your knowledge to the world!
 *
 * @author		xiaochong0302 <xiaochong0302@gmail.com>
 * @copyright	Copyright (c) 2011, Koogua Studio.
 * @license		http://www.qqas.org/user_guide/license.html
 * @link		http://www.qqas.org
 * @since		Version 1.0
 * @filesource
 */


class NavigationModel extends Model
{


	/**
	 * 获取navigation信息
	 *
	 * @param integer $navID
	 * @return array
	 */
	public function getNavigationByID($navID)
	{
		return $this->find($navID);
	}


	/**
	 * 删除navigation
	 *
	 * @param array $navID
	 * @return null
	 */
	public function deleteNavigationByID($navID)
	{
		$where['nav_id'] = array('in', $navID);
		return $this->where($where)->delete();
	}


	//缓存导航链接
	public function cacheNavigations()
	{
	    $results = $navigations = array();
    	$where = array('status' => 1);
    	$order = array('position' => 'asc', 'display_order' => 'asc');
    	$results = $this->where($where)->order($order)->select();
    	if (!empty($results))
    	{
    		foreach ($results as $value)
    		{
    			$navigations[$value['nav_id']] = $value;
    		}
    		F('cache_navigations', $navigations);
    	}
	}

}


/* End of file NavigationModel.class.php */
/* Location: ./App/Lib/Model/NavigationModel.class.php */
